Skip to content

SNOW-2912540: inline _create_temp_stage and _create_temp_file_format into analyzer_utils - #4308

Open
sfc-gh-fpawlowski wants to merge 6 commits into
SNOW-2912540-remove-connector-shimsfrom
SNOW-2912540-inline-pandas-staging-helpers
Open

SNOW-2912540: inline _create_temp_stage and _create_temp_file_format into analyzer_utils#4308
sfc-gh-fpawlowski wants to merge 6 commits into
SNOW-2912540-remove-connector-shimsfrom
SNOW-2912540-inline-pandas-staging-helpers

Conversation

@sfc-gh-fpawlowski

@sfc-gh-fpawlowski sfc-gh-fpawlowski commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Ports the _create_temp_stage and _create_temp_file_format implementations from the Universal Driver connector (PR snowflake-eng/drivers#518) directly into Snowpark's analyzer_utils.py, removing the dependency on these private snowflake.connector.pandas_tools symbols.

Changes:

  • analyzer_utils.py: Remove the three connector imports (_create_temp_stage, _create_temp_file_format, build_location_helper). Add local implementations of all staging helpers: _qualify_name / build_location_helper, _pandas_generate_temp_name, _pandas_create_temp_object, _stage_sql, _file_format_sql, _create_temp_stage, _create_temp_file_format.
  • Fix the _create_temp_file_format call site in write_arrow: the local impl maps compression internally (like PR SNOW-667858: to_pandas will only convert TimestampTypes to a native pandas date format, and not DateTypes #518), so the caller no longer pre-maps via compression_map[compression].
  • black-format the ported code, and suppress a pyright overload error on the two cursor.execute(..., _force_qmark_paramstyle=True) calls in _pandas_create_temp_object: _force_qmark_paramstyle is declared only on SnowflakeCursor.execute's real implementation signature in snowflake-connector-python, not on either of its two @overload stubs — a latent stub gap invisible while this code lived inside the connector package, now exposed since it lives in Snowpark's own pyright-checked source tree.

Companion: snowflake-eng/drivers#518 (which implements the same functions in the UD connector for its own write_pandas flow — the two implementations are kept in sync).

Checklist

  • I acknowledge that I have ensured my changes to be thread-safe

Stack (via Graphite)

🤖 Generated with Claude Code

sfc-gh-fpawlowski commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

@codecov-commenter

codecov-commenter commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.24390% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.24%. Comparing base (ef63724) to head (b7cbf51).

Files with missing lines Patch % Lines
...lake/snowpark/_internal/analyzer/analyzer_utils.py 90.24% 4 Missing ⚠️
Additional details and impacted files
@@                           Coverage Diff                           @@
##           SNOW-2912540-remove-connector-shims    #4308      +/-   ##
=======================================================================
- Coverage                                95.24%   95.24%   -0.01%     
=======================================================================
  Files                                      171      171              
  Lines                                    44755    44794      +39     
  Branches                                  7685     7687       +2     
=======================================================================
+ Hits                                     42629    42664      +35     
- Misses                                    1339     1343       +4     
  Partials                                   787      787              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sfc-gh-fpawlowski and others added 3 commits September 2, 2026 06:43
…into analyzer_utils

Removes the dependency on these private snowflake-connector-python functions
(previously imported from connector.pandas_tools). Ports the implementation
from universal-driver PR #518 directly into Snowpark so the connector no longer
needs to expose staging helpers as part of its public surface.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ned pandas staging helpers

black never ran on the ported code (4 blocks needed line-wrapping).
The two cursor.execute(..., _force_qmark_paramstyle=True) calls also
fail pyright: SnowflakeCursor.execute's two @overload stubs in
snowflake-connector-python never declare _force_qmark_paramstyle,
only the real implementation signature does. That gap was invisible
while this code lived in the connector package; porting it into
analyzer_utils.py exposes it to Snowpark's own pyright run.
…tings

_stage_sql (inlined from universal-driver PR #518 in the prior commit)
faithfully maps compression="gzip" to COMPRESSION=auto in the generated
CREATE...STAGE...FILE_FORMAT SQL, same as it already does for the COPY INTO
clause (see copy_compression in this test). The stage-creation assertion
still expected the literal "gzip", unlike its COPY INTO counterpart a few
lines below which already accounted for the auto mapping via
copy_compression. Update it to match.
@cursor
cursor Bot force-pushed the SNOW-2912540-remove-connector-shims branch from b245fcd to 9ab3e6a Compare September 2, 2026 06:45
@cursor
cursor Bot force-pushed the SNOW-2912540-inline-pandas-staging-helpers branch from 4292ad1 to 5812065 Compare September 2, 2026 06:45
cursoragent and others added 3 commits September 2, 2026 18:51
…inline-pandas-staging-helpers

Co-authored-by: Filip Pawłowski <sfc-gh-fpawlowski@users.noreply.github.com>
…inline-pandas-staging-helpers

Co-authored-by: Filip Pawłowski <sfc-gh-fpawlowski@users.noreply.github.com>
Comment on lines +2227 to +2236
def _qualify_name(
database: Optional[str],
schema: Optional[str],
name: str,
quote_identifiers: bool,
) -> str:
parts = [p for p in (database, schema, name) if p is not None]
if quote_identifiers:
parts = [_pandas_quote_identifier(p) for p in parts]
return ".".join(parts)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 MEDIUM · write_arrow builds COPY INTO / infer_schema SQL by interpolating stage/file-format names without escaping · CWE-89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants